﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:GameLogic_Logic="clr-namespace:GameLogic.Logic;assembly=GameLogic"
    mc:Ignorable="d"
    x:Class="Dodger.DodgerGame"
    d:DesignWidth="480"
    d:DesignHeight="800"
    Height="420"
    Width="700">

    <Grid
        x:Name="LayoutRoot"
        Background="#FF282041">
        <Custom:Interaction.Triggers>
            <GameLogic_Logic:GameLoopTickTrigger
                SourceName="LayoutRoot">
                <!--
                <GameLogic_Logic:ChangeGamePropertiesAction
                    ChangeScoresOnAction="True"
                    ScoresIncrementValue="1" />
                -->
            </GameLogic_Logic:GameLoopTickTrigger>
        </Custom:Interaction.Triggers>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup
                x:Name="GameStates">
                <VisualState
                    x:Name="Game">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetProperty="(UIElement.Visibility)"
                            Storyboard.TargetName="GameOverShade">
                            <DiscreteObjectKeyFrame
                                KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetProperty="(UIElement.Visibility)"
                            Storyboard.TargetName="border">
                            <DiscreteObjectKeyFrame
                                KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState
                    x:Name="LifeLost">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetProperty="(UIElement.Visibility)"
                            Storyboard.TargetName="GameOverShade">
                            <DiscreteObjectKeyFrame
                                KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetProperty="(UIElement.Visibility)"
                            Storyboard.TargetName="border">
                            <DiscreteObjectKeyFrame
                                KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState
                    x:Name="Over">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetProperty="(UIElement.Visibility)"
                            Storyboard.TargetName="GameOverShade">
                            <DiscreteObjectKeyFrame
                                KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetProperty="(UIElement.Visibility)"
                            Storyboard.TargetName="border">
                            <DiscreteObjectKeyFrame
                                KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Custom:Interaction.Behaviors>
            <GameLogic_Logic:GameLoop />
        </Custom:Interaction.Behaviors>
        <Rectangle
            x:Name="_left"
            HorizontalAlignment="Left"
            Width="10"
            Fill="#4C000000"
            Canvas.ZIndex="3">
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:StaticCollidableBehavior />
            </Custom:Interaction.Behaviors>
        </Rectangle>
        <Rectangle
            x:Name="_right"
            HorizontalAlignment="Right"
            Width="10"
            Fill="#4C000000"
            Canvas.ZIndex="3">
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:StaticCollidableBehavior />
            </Custom:Interaction.Behaviors>
        </Rectangle>
        <Rectangle
            x:Name="_top"
            VerticalAlignment="Top"
            Height="10"
            Fill="#4C000000"
            Canvas.ZIndex="3">
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:StaticCollidableBehavior />
            </Custom:Interaction.Behaviors>
        </Rectangle>
        <Rectangle
            x:Name="_bottom"
            VerticalAlignment="Bottom"
            Height="10"
            Fill="#4C000000"
            Canvas.ZIndex="3">
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:StaticCollidableBehavior />
            </Custom:Interaction.Behaviors>
        </Rectangle>
        <Rectangle
            x:Name="_enemy1"
            HorizontalAlignment="Left"
            Height="50"
            Margin="60,69,0,0"
            VerticalAlignment="Top"
            Width="50"
            RadiusX="2"
            RadiusY="2"
            StrokeThickness="2"
            Canvas.ZIndex="2">
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:MovingCollidableBehavior
                    CollisionEnabled="True"
                    CollisionType="Bounce"
                    AutoStart="True"
                    Direction="80"
                    Speed="2" />
            </Custom:Interaction.Behaviors>
            <Rectangle.Fill>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="#4C000000"
                        Offset="0" />
                    <GradientStop
                        Color="#CC000000"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Fill>
            <Rectangle.Stroke>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    MappingMode="RelativeToBoundingBox"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="Black"
                        Offset="0" />
                    <GradientStop
                        Color="#FFCC1F1F"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Stroke>
        </Rectangle>
        <Rectangle
            x:Name="_enemy2"
            HorizontalAlignment="Right"
            Height="50"
            Margin="0,103,74,0"
            VerticalAlignment="Top"
            Width="50"
            RadiusX="2"
            RadiusY="2"
            StrokeThickness="2"
            Canvas.ZIndex="2">
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:MovingCollidableBehavior
                    CollisionEnabled="True"
                    CollisionType="Bounce"
                    AutoStart="True"
                    Direction="12"
                    Speed="4" />
            </Custom:Interaction.Behaviors>
            <Rectangle.Fill>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="#4C000000"
                        Offset="0" />
                    <GradientStop
                        Color="#CC000000"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Fill>
            <Rectangle.Stroke>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    MappingMode="RelativeToBoundingBox"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="Black"
                        Offset="0" />
                    <GradientStop
                        Color="#FFCC1F1F"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Stroke>
        </Rectangle>
        <Rectangle
            x:Name="_enemy3"
            HorizontalAlignment="Left"
            Height="50"
            Margin="60,0,0,207"
            VerticalAlignment="Bottom"
            Width="50"
            RadiusX="2"
            RadiusY="2"
            StrokeThickness="2"
            Canvas.ZIndex="2">
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:MovingCollidableBehavior
                    CollisionEnabled="True"
                    CollisionType="Bounce"
                    AutoStart="True"
                    Direction="133"
                    Speed="4" />
            </Custom:Interaction.Behaviors>
            <Rectangle.Fill>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="#4C000000"
                        Offset="0" />
                    <GradientStop
                        Color="#CC000000"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Fill>
            <Rectangle.Stroke>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    MappingMode="RelativeToBoundingBox"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="Black"
                        Offset="0" />
                    <GradientStop
                        Color="#FFCC1F1F"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Stroke>
        </Rectangle>
        <Rectangle
            x:Name="_enemy4"
            Height="50"
            Margin="0,0,74,144"
            VerticalAlignment="Bottom"
            RadiusX="2"
            RadiusY="2"
            StrokeThickness="2"
            HorizontalAlignment="Right"
            Width="50"
            Canvas.ZIndex="2">
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:MovingCollidableBehavior
                    CollisionEnabled="True"
                    CollisionType="Bounce"
                    AutoStart="True"
                    Direction="34"
                    Speed="4" />
            </Custom:Interaction.Behaviors>
            <Rectangle.Fill>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="#4C000000"
                        Offset="0" />
                    <GradientStop
                        Color="#CC000000"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Fill>
            <Rectangle.Stroke>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    MappingMode="RelativeToBoundingBox"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="Black"
                        Offset="0" />
                    <GradientStop
                        Color="#FFCC1F1F"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Stroke>
        </Rectangle>
        <Rectangle
            x:Name="_enemy5"
            Height="50"
            Margin="175,0,175,45"
            VerticalAlignment="Bottom"
            RadiusX="2"
            RadiusY="2"
            StrokeThickness="2"
            Width="50"
            d:LayoutOverrides="HorizontalAlignment"
            Canvas.ZIndex="2">
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:MovingCollidableBehavior
                    CollisionEnabled="True"
                    CollisionType="Bounce"
                    AutoStart="True"
                    Direction="55"
                    Speed="4" />
            </Custom:Interaction.Behaviors>
            <Rectangle.Fill>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="#4C000000"
                        Offset="0" />
                    <GradientStop
                        Color="#CC000000"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Fill>
            <Rectangle.Stroke>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    MappingMode="RelativeToBoundingBox"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="Black"
                        Offset="0" />
                    <GradientStop
                        Color="#FFCC1F1F"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Stroke>
        </Rectangle>
        <Rectangle
            x:Name="_player"
            Height="50"
            VerticalAlignment="Center"
            RadiusX="2"
            RadiusY="2"
            StrokeThickness="2"
            RenderTransformOrigin="-2.2,1.5"
            HorizontalAlignment="Center"
            Width="50"
            Canvas.ZIndex="1">
            <Custom:Interaction.Triggers>
                <GameLogic_Logic:CollisionTrigger>
                    <!--
                    <GameLogic_Logic:ChangeGamePropertiesAction
                        ChangeLivesOnAction="True"
                        LivesIncrementValue="-1" />
                    -->
                </GameLogic_Logic:CollisionTrigger>
            </Custom:Interaction.Triggers>
            <Custom:Interaction.Behaviors>
                <GameLogic_Logic:FollowMouseBehavior />
                <GameLogic_Logic:StaticCollidableBehavior />
            </Custom:Interaction.Behaviors>
            <Rectangle.Fill>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="#4CFF7602"
                        Offset="0" />
                    <GradientStop
                        Color="#CCFF7602"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Fill>
            <Rectangle.Stroke>
                <LinearGradientBrush
                    EndPoint="0.5,1"
                    MappingMode="RelativeToBoundingBox"
                    StartPoint="0.5,0">
                    <GradientStop
                        Color="#FF7C4C35"
                        Offset="0" />
                    <GradientStop
                        Color="#FF1F1C1B"
                        Offset="1" />
                </LinearGradientBrush>
            </Rectangle.Stroke>
        </Rectangle>
        <Grid
            x:Name="GameOverShade"
            Background="#7F000000"
            Canvas.ZIndex="3">
            <Border
                BorderBrush="Black"
                BorderThickness="2"
                CornerRadius="2"
                Background="#33040303"
                Canvas.ZIndex="4"
                Padding="10"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Margin="0">
                <StackPanel
                    Orientation="Vertical">
                    <TextBlock
                        TextWrapping="Wrap"
                        Text="You're all out of lives!"
                        Canvas.ZIndex="4"
                        FontSize="32"
                        Height="47"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Foreground="#FFFBFBFB" />
                    <StackPanel
                        x:Name="_highscoreBox"
                        Orientation="Vertical"
                        Width="505">
                        <StackPanel
                            Orientation="Horizontal"
                            d:LayoutOverrides="Width">
                            <TextBlock
                                TextWrapping="Wrap"
                                Canvas.ZIndex="4"
                                FontSize="21.333"
                                Foreground="#FFFBFBFB"
                                TextAlignment="Center"
                                Text="But you made it to Rank " />
                            <TextBlock
                                x:Name="_highscoreRank"
                                TextWrapping="Wrap"
                                Canvas.ZIndex="4"
                                FontSize="21.333"
                                Foreground="#FFFBFBFB"
                                TextAlignment="Center"
                                Text="X" />
                            <TextBlock
                                TextWrapping="Wrap"
                                Canvas.ZIndex="4"
                                FontSize="21.333"
                                Foreground="#FFFBFBFB"
                                TextAlignment="Center"
                                Text=" of the highscore list" />
                        </StackPanel>
                        <TextBlock
                            TextWrapping="Wrap"
                            Canvas.ZIndex="4"
                            FontSize="21.333"
                            Foreground="#FFFBFBFB"
                            TextAlignment="Center"
                            Text="Please enter your name:"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center" />
                        <TextBox
                            x:Name="_playerName"
                            TextWrapping="Wrap"
                            FontSize="16"
                            TextAlignment="Center"
                            Width="100" />
                    </StackPanel>
                    
                </StackPanel>
            </Border>
        </Grid>
        <Border
            x:Name="border"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            BorderBrush="Black"
            BorderThickness="2"
            CornerRadius="2"
            Background="#33040303"
            Canvas.ZIndex="4"
            Margin="0"
            Padding="10">
            <StackPanel
                Orientation="Vertical"
                Width="497">
                <TextBlock
                    TextWrapping="Wrap"
                    Text="Don't touch the moving boxes!"
                    Canvas.ZIndex="4"
                    FontSize="32"
                    Height="47"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Foreground="#FFFBFBFB" />
                <Button
                    x:Name="_continue"
                    Content="Continue"
                    HorizontalAlignment="Center"
                    Click="_continue_Click" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>